# -*- coding: utf-8 -*-

'''
Created on 2011/04/15

@author: Edgar Pereira
Nº 6207

Dialog to Open a CSV File
'''

from Tkinter import *
import tkFileDialog
import os

class MyFlOpen():
    def _init__(self):
        pass
    
    #creates the dialog for user to choose the file to open
    def open(self):       
        dialog = Tk()
        dialog.withdraw() #hiding tkinter window
        file = tkFileDialog.askopenfilename(title="Open file", filetypes=[("txt file",".csv")])
         
        if file != "": # if file not Null
            print "The file ", file, " will open"
            os.system('leafpad {0}'.format(file)) # open the file with Leafpad
        else:
            print "you didn't open anything!"
            
        dialog.quit()
        print('Ok')
    pass
    
##mfo = MyFlOpen()
##mfo.open()
